_Pragma("once");

#include <string>

#include "Editor.h"
#include "IButtonListener.h"

class Button : public BasicEditor {
    using super = BasicEditor;
public:
    /** Default constructor */
    Button(int lineNum, int startPos, int endPos, const std::string& text, IButtonListener* const plistener, const uint16_t id);
    /** Default destructor */
    virtual ~Button();



    int onKeyDown(const KeyCode& keyCode) override  {
        if (mplistener) {
            mplistener->onClick(mid, this);
        }

        return 1;
    }

    /**
     * UP键 数值增加
     */
    int onKeyUp(const KeyCode& keyCode) override {

        return 0;
    }


    const std::string& getText() override {
        return textBuffer;
    }

    const uint16_t mid;
    IButtonListener*const mplistener;
};


